package unionfind;

import java.util.Random;

public class UnionFindTest {

    public static double test(UF uf, int size, int m) {
        Random random = new Random();

        long startTime = System.nanoTime();

        for (int i = 0; i < size; i++) {
            int a = random.nextInt(size);
            int b = random.nextInt(size);
            uf.union(a, b);
        }
        for (int i = 0; i < size; i++) {
            int a = random.nextInt(size);
            int b = random.nextInt(size);
            uf.isConnected(a, b);
        }

        long endTime = System.nanoTime();

        return (endTime - startTime) / 1000000000.0;
    }

    public static void main(String[] args) {
        int size = 10000000;
        int m = 10000000;
//        UF uf = new UnionFind(size);
//        System.out.println("UnionFind:" + test(uf, size, m));
//
//        UF uf2 = new UnionFind2(size);
//        System.out.println("UnionFind2:" + test(uf2, size, m));

        UF uf3 = new UnionFind3(size);
        System.out.println("UnionFind3:" + test(uf3, size, m));

        UF uf4 = new UnionFind4(size);
        System.out.println("UnionFind4:" + test(uf4, size, m));

        UF uf5 = new UnionFind5(size);
        System.out.println("UnionFind5:" + test(uf5, size, m));

        UF uf6 = new UnionFind6(size);
        System.out.println("UnionFind5:" + test(uf6, size, m));


    }
}
